<template>
  <div class="caseComp">
    <div class="caseCompTitle">编辑办理情况</div>
    <el-form
      :model="initInfo"
      :rules="rules"
      ref="ruleForm"
      label-width="100px"
    >
      <el-row>
        <el-col :span="24">
          <el-form-item label="办理情况" prop="handleSituation">
            <el-input
              v-model="initInfo.handleSituation"
              clearable=""
              placeholder="请输入"
              class="caseCompTitleInput"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="办结存档" prop="isArchive">
            <el-select v-model="initInfo.isArchive" placeholder="请选择">
              <el-option label="办结" value="办结"></el-option>
              <el-option label="待办" value="待办"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="备注" prop="remark" width="100%">
            <el-input
              v-model="initInfo.remark"
              clearable=""
              placeholder="请输入"
              class="caseCompTitleInput"
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div class="caseCompBtn">
      <el-button type="primary" class="commonBut saveBtn" @click="save"
        >保存</el-button
      >
      <el-button type="default" class="commonBut" @click="finish"
        >取消</el-button
      >
    </div>
  </div>
</template>
<script>
import { mapActions, mapState } from 'vuex'

export default {
  name: 'caseDepartment',
  props: {
    childData: {
      type: Object,
      required: true,
      default() {
        return {}
      },
    },
  },
  data() {
    var checkMoney = (rule, value, callback) => {
      if (!value) {
        callback()
      } else {
        var rePayTotal =
          /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/
        if (!rePayTotal.test(value) || value == 0.0 || value == 0.0) {
          callback(new Error('金额格式不正确,必须大于0,最多带有2位小数'))
        } else {
          if (value >= 100000000000) {
            callback(new Error('金额需小于1000亿'))
          } else {
            callback()
          }
        }
      }
    }
    return {
      taskAreaId: [],
      involveCount: '',
      initInfo: {
        id: '',
        handleSituation: '',
        isArchive: '',
        remark: '',
      },
      rules: {
        handleSituation: [
          { max: 200, message: '最多输入200个字', trigger: 'blur' },
        ],
        isArchive: [{ required: true, message: '请选择', trigger: 'change' }],
        remark: [{ max: 200, message: '最多输入200个字', trigger: 'blur' }],
      },
    }
  },
  mounted() {
    this.initInfo = JSON.parse(JSON.stringify(this.childData))
  },
  methods: {
    save() {
      let params = this.initInfo
      delete params.createTime
      delete params.isDeleted
      delete params.effectiveStartDate
      delete params.effectiveEndDate
      delete params.creatorId
      delete params.updateTime
      delete params.updaterId
      this.$refs.ruleForm.validate((valid) => {
        if (valid) {
          this.axios
            .post('api-r/complaint/registration/edit', params)
            .then((res) => {
              if (!res.data.hasError) {
                this.$message({
                  type: 'success',
                  message: '修改成功',
                })
                this.isLoading = false
                this.finish(1)
              } else {
                this.$message({
                  type: 'warning',
                  message: res.data.errorMsg || '修改失败',
                })
                this.isLoading = false
              }
            })
        } else {
        }
      })
    },
    finish(index) {
      this.$emit('callback', { success: index == 1 ? true : false })
    },
  },
}
</script>
<style lang="less" scoped>
.caseComp {
  border: 1px solid #dcdfe6;
  background-color: #f8f9fb;
  padding: 15px;
  &Title {
    color: #009588;
    font-size: 14px;
    line-height: 30px;
    margin-bottom: 12px;
  }
  &List {
    line-height: 36px;
    height: 36px;
    font-size: 14px;
    color: #444;
    margin-bottom: 12px;
    &Title {
      display: inline-block;
      width: 85px;
      text-align: right;
    }
    &Input {
      width: calc(100% - 95px);
    }
    .input {
      width: calc(100% - 170px);
    }
  }
  &Btn {
    text-align: center;
    margin: 24px 0 10px;
    .el-button {
      width: 120px;
    }
  }
  /deep/ .el-radio__input.is-checked + .el-radio__label {
    color: #009588 !important;
  }
  /deep/.el-radio__input.is-checked .el-radio__inner {
    background: #009588 !important;
    border-color: #009588 !important;
  }
}
.caseCompTitleInput {
  width: calc(100% - 20px);
}
</style>
